package com.yc;

import com.yc.cinema.bean.User;
import com.yc.spring.IocConfig;
import com.yc.spring.bbs.bean.Page;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class SpringTest2 {
    @Test
    public void test(){
        ApplicationContext cxt = new AnnotationConfigApplicationContext(IocConfig.class);

        User user1 = cxt.getBean(User.class);
        User user2 = (User) cxt.getBean("user2");

        System.out.println("user1 = " + user1);
        System.out.println("user2 = " + user2);

        System.out.println(user1 == user2); //false   两个不同的实例


    }

    @Test
    public void test2(){
        ApplicationContext cxt = new AnnotationConfigApplicationContext(IocConfig.class);
        Page page = (Page) cxt.getBean("myBean");
        Assert.assertEquals(10000,page.getTotal());
    }
}
